Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Strip leading zeros in signature v and s values coming from the mirror node, in tests. #3241

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

ebadiere
Copy link
Contributor

@ebadiere ebadiere commented Nov 8, 2024

Description:
Test fix. Ethereum transaction signatures v and s values need to have leading zeros stripped before being evaluated.

Related issue(s):

Fixes #3239

Notes for reviewer:

Leading zeros on signature r and s values are stripped in the formatters.formatContractResult in the relay before the results are returned. On the mirror node they are stored with the leading zero. e.g.
The transaction hash 0xc5a3df675c99f634d9d81a8092fc65db54d7c28dc21126439329e92598976d2d on testnet returns a signature s value of:
0x091027721aff181da255f7bda0cf5b834a0d5099b46dc636b1dbd50a30e33383 from the mirror node.
The eth_getTransactionReceipt response from the relay returns a signature s value of 0x91027721aff181da255f7bda0cf5b834a0d5099b46dc636b1dbd50a30e33383

curl --location 'https://testnet.hashio.io/api' \
--header 'Content-Type: application/json' \
--header 'Request-Id: testRequest' \
--data '{
  "id": 1,
  "jsonrpc": "2.0",
  "params": [
    "0xc5a3df675c99f634d9d81a8092fc65db54d7c28dc21126439329e92598976d2d"
  ],
  "method": "eth_getTransactionByHash"
}'

The leading zeros in the v and s signature values will cause json: cannot unmarshal hex number with leading zero digits into Go struct field txJSON.s of type *hexutil.Big in the go-ethereum client.

Some tests verify the signature v and s values using the response from the mirror node, but these values need to strip the leading zeros before being evaluated.

@ebadiere ebadiere self-assigned this Nov 8, 2024
@ebadiere ebadiere added the bug Something isn't working label Nov 8, 2024
@ebadiere ebadiere added this to the 0.60.0 milestone Nov 8, 2024
Copy link

sonarcloud bot commented Nov 8, 2024

Copy link

github-actions bot commented Nov 8, 2024

Test Results

 18 files  + 17  251 suites  +242   32m 1s ⏱️ + 31m 24s
607 tests +601  602 ✅ +596  4 💤 +4  1 ❌ +1 
661 runs  +599  656 ✅ +594  4 💤 +4  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 4b5c0ba. ± Comparison against base commit 3bd07ef.

♻️ This comment has been updated with latest results.

@ebadiere ebadiere changed the title fix: 3239 strip leading zeros fix: strip leading zeros in signature v and s values coming from the mirror node, in tests. Nov 8, 2024
@ebadiere ebadiere changed the title fix: strip leading zeros in signature v and s values coming from the mirror node, in tests. fix: Strip leading zeros in signature v and s values coming from the mirror node, in tests. Nov 8, 2024
@ebadiere ebadiere merged commit a541583 into main Nov 11, 2024
50 of 52 checks passed
@ebadiere ebadiere deleted the 3239-strip-leading-zeros branch November 11, 2024 15:57
@quiet-node quiet-node added Internal For changes that affect the project's internal workings but not its outward-facing functionality. and removed bug Something isn't working labels Nov 12, 2024
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.17%. Comparing base (3bd07ef) to head (4b5c0ba).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3241   +/-   ##
=======================================
  Coverage   83.17%   83.17%           
=======================================
  Files          66       66           
  Lines        4314     4314           
  Branches      843      843           
=======================================
  Hits         3588     3588           
  Misses        483      483           
  Partials      243      243           
Flag Coverage Δ
config-service 98.14% <ø> (ø)
relay 85.29% <ø> (ø)
server 83.52% <ø> (ø)
ws-server 36.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal For changes that affect the project's internal workings but not its outward-facing functionality.
Projects
Status: Done
3 participants